﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Text;
using System.Data;
using Catering_Rules;
using Catering.View_Operaction;

namespace Catering.Catering_Page.AjaxHandler
{
    /// <summary>
    /// WebServiceKFSZ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class WebServiceKFSZ : System.Web.Services.WebService
    {
        /// <summary>
        /// 获取现在库存报警数据信息
        /// </summary>
        /// <param name="AreaID">作业区</param>
        /// <param name="ClassID">班组</param>
        /// <param name="OrderBy">排序条件</param>
        /// <param name="pageIndex">当前页数</param>
        /// <param name="pageSize">每页记录数量</param>
        /// <returns></returns>
        [WebMethod]
        public string GetRoomWaingList(int AreaID, int ClassID, string OrderBy, int pageIndex, int pageSize)
        {
            StringBuilder result = new StringBuilder("");
            string whereClause = " WHERE 1=1 ";//查询条件
            string orderClause = " ORDER BY ClassID ";//排序条件
            if (AreaID > 0)
            {
                whereClause += " AND GroupID=" + AreaID + " ";
            }
            if (ClassID > 0)
            {
                whereClause += " AND ClassID=" + ClassID + " ";
            }
            if (!string.IsNullOrEmpty(OrderBy)) orderClause = " ORDER BY " + OrderBy + " ";
            RoomWaing rmv = new RoomWaing();
            int sumCount = rmv.GetRoomWaingCount(whereClause);//警戒线数量
            if (sumCount > 0)
            {
                int pageNum = 0;//总页数、末页
                int prePage = 0;  //上一页
                int nextPage = 0; //下一页
                if (sumCount % pageSize == 0)
                {
                    pageNum = sumCount / pageSize;
                }
                else
                {
                    pageNum = sumCount / pageSize + 1;
                }
                prePage = pageIndex > 1 ? (pageIndex - 1) : 1;
                nextPage = pageIndex == pageNum ? pageIndex : (pageIndex + 1);

                DataTable dt = rmv.GetRoomWaingList(pageSize, pageIndex, whereClause, orderClause);
                if (dt != null && dt.Rows.Count > 0)
                {
                    result.Append("<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
                    result.Append("<tr>");
                    result.Append("<th width='25%'><a href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'GroupID',1," + pageSize + ")\">作业区</a></th>");
                    result.Append("<th width='25%'><a href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'ClassID',1," + pageSize + ")\">班组</a></th>");
                    result.Append("<th width='25%'><a href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'RawID',1," + pageSize + ")\">原料名称</a></th>");
                    result.Append("<th width='25%'>状态</th>");
                    result.Append("</tr>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (!(dt.Rows[i]["RawID"] is DBNull))
                        {
                            int rm_Rawid = Convert.ToInt32(dt.Rows[i]["RawID"]);
                            int rm_Groupid = Convert.ToInt32(dt.Rows[i]["GroupID"]);
                            int rm_Classid = Convert.ToInt32(dt.Rows[i]["ClassID"]);
                            float rm_MaxContent = Convert.ToSingle(dt.Rows[i]["MaxContent"]);
                            float rm_MinContent = Convert.ToSingle(dt.Rows[i]["MinContent"]);
                            float rm_Temp1 = 0;
                            if (!(dt.Rows[i]["Temp1"] is DBNull) && dt.Rows[i]["Temp1"].ToString() != "")
                            {
                                rm_Temp1 = Convert.ToSingle(dt.Rows[i]["Temp1"]);
                            }
                            string rawName = new Catering_Rules.T_RawMaterial().GetModel(rm_Rawid).RAWName;
                            string stateStr = rm_Temp1 > rm_MaxContent ? "超过最大库存量" : (rm_Temp1 < rm_MinContent ? "低于库存警戒线" : "");
                            string areaName = new Catering_Rules.OperationArea().GetModel(Convert.ToInt32(rm_Groupid)).AreaName;
                            string className = new Catering_Rules.ClassInfo().GetModel(Convert.ToInt32(rm_Classid)).CName;
                            if (!string.IsNullOrEmpty(stateStr))
                            {
                                result.Append("<tr style='background-color:#ffffff;' onmouseover=\"this.style.background='#E3F5FF'\" onmouseout=\"this.style.background='#FFFFFF'\">");
                                result.Append("<td>" + areaName + "</td>");
                                result.Append("<td>" + className + "</td>");
                                result.Append("<td>" + rawName + "</td>");
                                result.Append("<td>" + stateStr + "</td>");
                                result.Append("</tr>");
                            }
                        }
                    }
                    dt.Dispose();
                    result.Append("<tr>");
                    result.Append("<td colspan='4'>");
                    result.Append("<div class='paper_n'>");
                    result.Append("<ul>");
                    result.Append("<li class='paper_H'><a ID='InkFirst' href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'" + OrderBy + "',1," + pageSize + ")\">首页</a></li>");
                    result.Append("<li class='paper_U'><a ID='InkPrev' href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'" + OrderBy + "'," + prePage + "," + pageSize + ")\">上一页</a></li>");
                    result.Append("<li class='paper_D'><a ID='InkNext'  href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'" + OrderBy + "'," + nextPage + "," + pageSize + ")\">下一页</a></li>");
                    result.Append("<li class='paper_F'><a ID='InkLast'  href=\"javascript:GetData(" + AreaID + "," + ClassID + ",'" + OrderBy + "'," + pageNum + "," + pageSize + ")\">末页</a></li>");
                    result.Append("</ul>");
                    result.Append("</div>");
                    result.Append("<div class='paper_n2'>");
                    result.Append("<span id='lblCurPage'>第" + pageIndex + "/" + pageNum + "页</span>");
                    result.Append("　<span id='Label6'>每页" + pageSize + "条</span>");
                    result.Append("</div>");
                    result.Append("</td>");
                    result.Append("</tr>");
                    result.Append("</table>");
                }
            }
            return result.ToString();
        }

        [WebMethod]
        public string GetDailyManagementList(string StrStartTime, string StrEndTime, int pageIndex, int pageSize, string UserSession)
        {
            StringBuilder result = new StringBuilder("");
            string whereClause = " WHERE Repair!='' AND LTRIM(Repair) NOT LIKE '无事%' ";//查询条件
            string orderClause = " ORDER BY Date DESC ";//排序条件
            DateTime StartTime = DateTime.Now.AddMonths(-1);
            DateTime EndTime = DateTime.Now;
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            if (!string.IsNullOrEmpty(StrStartTime) && !string.IsNullOrEmpty(StrEndTime))
            {
                try
                {
                    StartTime = Convert.ToDateTime(StrStartTime);
                    EndTime = Convert.ToDateTime(StrEndTime);
                }
                catch
                {
                    StartTime = DateTime.Now.AddMonths(-1);
                    EndTime = DateTime.Now;
                }
            }
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return "";
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;

            whereClause += " AND Date BETWEEN '" + StartTime.ToString("yyyy-MM-dd") + "' AND '" + EndTime.ToString("yyyy-MM-dd") + "' ";
            if (!isAdmin) whereClause += " AND ClassID=" + classid + " ";

            DailyManagement dm = new DailyManagement();
            int sumCount = dm.GetDailyManagementListCount(whereClause);//维修报警数量
            if (sumCount > 0)
            {
                int pageNum = 0;//总页数、末页
                int prePage = 0;  //上一页
                int nextPage = 0; //下一页
                if (sumCount % pageSize == 0)
                {
                    pageNum = sumCount / pageSize;
                }
                else
                {
                    pageNum = sumCount / pageSize + 1;
                }
                prePage = pageIndex > 1 ? (pageIndex - 1) : 1;
                nextPage = pageIndex == pageNum ? pageIndex : (pageIndex + 1);

                DataTable dt = dm.GetDailyManagementList(pageSize, pageIndex, whereClause, orderClause);
                if (dt != null && dt.Rows.Count > 0)
                {
                    bool flag = false;//是否有删除的权限
                    if (Catering.Toolss.IsVerification(userrole.ToString(), "wxbj.aspx", "操作")) flag = true;
                    result.Append("<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
                    result.Append("<tr>");
                    if (flag)//有删除的权限
                    {
                        result.Append("<th width='6%'><input type='checkbox' name='wxbj_checkall' id='wxbj_checkall' onclick=\"SetDeletCheckBox(this,'wxbj')\" /></th>");
                        result.Append("<th width='6%'>序号</th>");
                        result.Append("<th width='16%'>报警日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>报警内容</th>");
                    }
                    else//无删除的权限
                    {
                        result.Append("<th width='10%'>序号</th>");
                        result.Append("<th width='18%'>报警日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>报警内容</th>");
                    }
                    result.Append("</tr>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int rm_RowNum = Convert.ToInt32(dt.Rows[i]["rowNum"]);
                        int rm_Id = Convert.ToInt32(dt.Rows[i]["id"]);
                        DateTime rm_Date = Convert.ToDateTime(dt.Rows[i]["Date"]);
                        string rm_CName = dt.Rows[i]["CName"].ToString();
                        string rm_Repair = dt.Rows[i]["Repair"].ToString();
                        result.Append("<tr style='background-color:#ffffff;' onmouseover=\"this.style.background='#E3F5FF'\" onmouseout=\"this.style.background='#FFFFFF'\">");
                        if (flag)//有删除的权限
                        {
                            result.Append("<td><input type='checkbox' name='wxbj_checkbox' value='" + rm_Id + "' id='wxbj_checkbox" + i + "' /></th>");
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_Repair + "</td>");
                        }
                        else//无删除的权限
                        {
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_Repair + "</td>");
                        }
                        result.Append("</tr>");
                    }
                    dt.Dispose();
                    result.Append("<tr>");
                    if (flag)
                    {
                        result.Append("<td colspan='2' align='center'>");
                        result.Append("<input type='button' class='input_btn_a' value='删　除' onclick='DeleWXBJ()' style='margin-left:20px;' />");
                        result.Append("</td>");
                        result.Append("<td colspan='3'>");
                    }
                    else
                    {
                        result.Append("<td colspan='4'>");
                    }
                    result.Append("<div class='paper_n'>");
                    result.Append("<ul>");
                    result.Append("<li class='paper_H'><a ID='InkFirst' href=\"javascript:GetWXBJData('" + StrStartTime + "','" + StrEndTime + "',1," + pageSize + ",'" + UserSession + "')\">首页</a></li>");
                    result.Append("<li class='paper_U'><a ID='InkPrev' href=\"javascript:GetWXBJData('" + StrStartTime + "','" + StrEndTime + "'," + prePage + "," + pageSize + ",'" + UserSession + "')\">上一页</a></li>");
                    result.Append("<li class='paper_D'><a ID='InkNext'  href=\"javascript:GetWXBJData('" + StrStartTime + "','" + StrEndTime + "'," + nextPage + "," + pageSize + ",'" + UserSession + "')\">下一页</a></li>");
                    result.Append("<li class='paper_F'><a ID='InkLast'  href=\"javascript:GetWXBJData('" + StrStartTime + "','" + StrEndTime + "'," + pageNum + "," + pageSize + ",'" + UserSession + "')\">末页</a></li>");
                    result.Append("</ul>");
                    result.Append("</div>");
                    result.Append("<div class='paper_n2'>");
                    result.Append("<span id='lblCurPage'>第" + pageIndex + "/" + pageNum + "页</span>");
                    result.Append("　<span id='Label6'>每页" + pageSize + "条</span>");
                    result.Append("</div>");
                    result.Append("</td>");
                    result.Append("</tr>");
                    result.Append("</table>");
                }
            }
            return result.ToString();
        }

        [WebMethod]
        public string GetAQYHDataList(string StrStartTime, string StrEndTime, int pageIndex, int pageSize, string UserSession)
        {
            StringBuilder result = new StringBuilder("");
            string whereClause = " WHERE temp2 IS NOT NULL AND temp2!='' AND LTRIM(temp2) NOT LIKE '无事%' ";//查询条件
            string orderClause = " ORDER BY Date DESC ";//排序条件
            DateTime StartTime = DateTime.Now.AddMonths(-1);
            DateTime EndTime = DateTime.Now;
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            if (!string.IsNullOrEmpty(StrStartTime) && !string.IsNullOrEmpty(StrEndTime))
            {
                try
                {
                    StartTime = Convert.ToDateTime(StrStartTime);
                    EndTime = Convert.ToDateTime(StrEndTime);
                }
                catch
                {
                    StartTime = DateTime.Now.AddMonths(-1);
                    EndTime = DateTime.Now;
                }
            }
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return "";
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;
            whereClause += " AND Date BETWEEN '" + StartTime.ToString("yyyy-MM-dd") + "' AND '" + EndTime.ToString("yyyy-MM-dd") + "' ";
            if (!isAdmin) whereClause += " AND ClassID=" + classid + " ";
            DailyManagement dm = new DailyManagement();
            int sumCount = dm.GetDailyManagementListCount(whereClause);//维修报警数量
            if (sumCount > 0)
            {
                int pageNum = 0;//总页数、末页
                int prePage = 0;  //上一页
                int nextPage = 0; //下一页
                if (sumCount % pageSize == 0)
                {
                    pageNum = sumCount / pageSize;
                }
                else
                {
                    pageNum = sumCount / pageSize + 1;
                }
                prePage = pageIndex > 1 ? (pageIndex - 1) : 1;
                nextPage = pageIndex == pageNum ? pageIndex : (pageIndex + 1);

                DataTable dt = dm.GetDailyManagementList(pageSize, pageIndex, whereClause, orderClause);
                if (dt != null && dt.Rows.Count > 0)
                {
                    bool flag = false;//是否有删除的权限
                    if (Catering.Toolss.IsVerification(userrole.ToString(), "aqyh.aspx", "操作")) flag = true;
                    result.Append("<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
                    result.Append("<tr>");
                    if (flag)//有删除的权限
                    {
                        result.Append("<th width='6%'><input type='checkbox' name='aqyh_checkall' id='aqyh_checkall' onclick=\"SetDeletCheckBox(this,'aqyh')\" /></th>");
                        result.Append("<th width='6%'>序号</th>");
                        result.Append("<th width='16%'>日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>安全隐患</th>");
                    }
                    else//无删除的权限
                    {
                        result.Append("<th width='10%'>序号</th>");
                        result.Append("<th width='18%'>日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>安全隐患</th>");
                    }
                    result.Append("</tr>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int rm_RowNum = Convert.ToInt32(dt.Rows[i]["rowNum"]);
                        int rm_Id = Convert.ToInt32(dt.Rows[i]["id"]);
                        DateTime rm_Date = Convert.ToDateTime(dt.Rows[i]["Date"]);
                        string rm_CName = dt.Rows[i]["CName"].ToString();
                        string rm_Temp2 = dt.Rows[i]["temp2"].ToString();
                        result.Append("<tr style='background-color:#ffffff;' onmouseover=\"this.style.background='#E3F5FF'\" onmouseout=\"this.style.background='#FFFFFF'\">");
                        if (flag)//有删除的权限
                        {
                            result.Append("<td><input type='checkbox' name='aqyh_checkbox' value='" + rm_Id + "' id='aqyh_checkbox" + i + "' /></th>");
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_Temp2 + "</td>");
                        }
                        else//无删除的权限
                        {
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_Temp2 + "</td>");
                        }
                        result.Append("</tr>");
                    }
                    dt.Dispose();
                    result.Append("<tr>");
                    if (flag)
                    {
                        result.Append("<td colspan='2' align='center'>");
                        result.Append("<input type='button' class='input_btn_a' value='删　除' onclick='DeleAQYH()' style='margin-left:20px;' />");
                        result.Append("</td>");
                        result.Append("<td colspan='3'>");
                    }
                    else
                    {
                        result.Append("<td colspan='4'>");
                    }
                    result.Append("<div class='paper_n'>");
                    result.Append("<ul>");
                    result.Append("<li class='paper_H'><a ID='InkFirst' href=\"javascript:GetAQYHData('" + StrStartTime + "','" + StrEndTime + "',1," + pageSize + ",'" + UserSession + "')\">首页</a></li>");
                    result.Append("<li class='paper_U'><a ID='InkPrev' href=\"javascript:GetAQYHData('" + StrStartTime + "','" + StrEndTime + "'," + prePage + "," + pageSize + ",'" + UserSession + "')\">上一页</a></li>");
                    result.Append("<li class='paper_D'><a ID='InkNext'  href=\"javascript:GetAQYHData('" + StrStartTime + "','" + StrEndTime + "'," + nextPage + "," + pageSize + ",'" + UserSession + "')\">下一页</a></li>");
                    result.Append("<li class='paper_F'><a ID='InkLast'  href=\"javascript:GetAQYHData('" + StrStartTime + "','" + StrEndTime + "'," + pageNum + "," + pageSize + ",'" + UserSession + "')\">末页</a></li>");
                    result.Append("</ul>");
                    result.Append("</div>");
                    result.Append("<div class='paper_n2'>");
                    result.Append("<span id='lblCurPage'>第" + pageIndex + "/" + pageNum + "页</span>");
                    result.Append("　<span id='Label6'>每页" + pageSize + "条</span>");
                    result.Append("</div>");
                    result.Append("</td>");
                    result.Append("</tr>");
                    result.Append("</table>");
                }
            }
            return result.ToString();
        }

        [WebMethod]
        public string GetSLYSDataList(string StrStartTime, string StrEndTime, int pageIndex, int pageSize, string UserSession)
        {
            StringBuilder result = new StringBuilder("");
            string whereClause = " WHERE DishTest IS NOT NULL AND DishTest!='' AND LTRIM(DishTest) NOT LIKE '合格%' ";//查询条件
            string orderClause = " ORDER BY Date DESC ";//排序条件
            DateTime StartTime = DateTime.Now.AddMonths(-1);
            DateTime EndTime = DateTime.Now;
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            if (!string.IsNullOrEmpty(StrStartTime) && !string.IsNullOrEmpty(StrEndTime))
            {
                try
                {
                    StartTime = Convert.ToDateTime(StrStartTime);
                    EndTime = Convert.ToDateTime(StrEndTime);
                }
                catch
                {
                    StartTime = DateTime.Now.AddMonths(-1);
                    EndTime = DateTime.Now;
                }
            }
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return "";
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;
            whereClause += " AND Date BETWEEN '" + StartTime.ToString("yyyy-MM-dd") + "' AND '" + EndTime.ToString("yyyy-MM-dd") + "' ";
            if (!isAdmin) whereClause += " AND ClassID=" + classid + " ";
            DailyManagement dm = new DailyManagement();
            int sumCount = dm.GetDailyManagementListCount(whereClause);//维修报警数量
            if (sumCount > 0)
            {
                int pageNum = 0;//总页数、末页
                int prePage = 0;  //上一页
                int nextPage = 0; //下一页
                if (sumCount % pageSize == 0)
                {
                    pageNum = sumCount / pageSize;
                }
                else
                {
                    pageNum = sumCount / pageSize + 1;
                }
                prePage = pageIndex > 1 ? (pageIndex - 1) : 1;
                nextPage = pageIndex == pageNum ? pageIndex : (pageIndex + 1);

                DataTable dt = dm.GetDailyManagementList(pageSize, pageIndex, whereClause, orderClause);
                if (dt != null && dt.Rows.Count > 0)
                {
                    bool flag = false;//是否有删除的权限
                    if (Catering.Toolss.IsVerification(userrole.ToString(), "aqyh.aspx", "操作")) flag = true;
                    result.Append("<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
                    result.Append("<tr>");
                    if (flag)//有删除的权限
                    {
                        result.Append("<th width='6%'><input type='checkbox' name='slys_checkbox' id='slys_checkall' onclick=\"SetDeletCheckBox(this,'slys')\" /></th>");
                        result.Append("<th width='6%'>序号</th>");
                        result.Append("<th width='16%'>日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>上料验收</th>");
                    }
                    else//无删除的权限
                    {
                        result.Append("<th width='10%'>序号</th>");
                        result.Append("<th width='18%'>日期</th>");
                        result.Append("<th width='25%'>班组</th>");
                        result.Append("<th width='47%'>上料验收</th>");
                    }
                    result.Append("</tr>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int rm_RowNum = Convert.ToInt32(dt.Rows[i]["rowNum"]);
                        int rm_Id = Convert.ToInt32(dt.Rows[i]["id"]);
                        DateTime rm_Date = Convert.ToDateTime(dt.Rows[i]["Date"]);
                        string rm_CName = dt.Rows[i]["CName"].ToString();
                        string rm_DishTest = dt.Rows[i]["DishTest"].ToString();
                        result.Append("<tr style='background-color:#ffffff;' onmouseover=\"this.style.background='#E3F5FF'\" onmouseout=\"this.style.background='#FFFFFF'\">");
                        if (flag)//有删除的权限
                        {
                            result.Append("<td><input type='checkbox' name='slys_checkbox' value='" + rm_Id + "' id='slys_checkbox" + i + "' /></th>");
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_DishTest + "</td>");
                        }
                        else//无删除的权限
                        {
                            result.Append("<td>" + rm_RowNum + "</td>");
                            result.Append("<td>" + rm_Date.ToString("yyyy-MM-dd") + "</td>");
                            result.Append("<td>" + rm_CName + "</td>");
                            result.Append("<td>" + rm_DishTest + "</td>");
                        }
                        result.Append("</tr>");
                    }
                    dt.Dispose();
                    result.Append("<tr>");
                    if (flag)
                    {
                        result.Append("<td colspan='2' align='center'>");
                        result.Append("<input type='button' class='input_btn_a' value='删　除' onclick='DeleSLYS()' style='margin-left:20px;' />");
                        result.Append("</td>");
                        result.Append("<td colspan='3'>");
                    }
                    else
                    {
                        result.Append("<td colspan='4'>");
                    }
                    result.Append("<div class='paper_n'>");
                    result.Append("<ul>");
                    result.Append("<li class='paper_H'><a ID='InkFirst' href=\"javascript:GetSLYSData('" + StrStartTime + "','" + StrEndTime + "',1," + pageSize + ",'" + UserSession + "')\">首页</a></li>");
                    result.Append("<li class='paper_U'><a ID='InkPrev' href=\"javascript:GetSLYSData('" + StrStartTime + "','" + StrEndTime + "'," + prePage + "," + pageSize + ",'" + UserSession + "')\">上一页</a></li>");
                    result.Append("<li class='paper_D'><a ID='InkNext'  href=\"javascript:GetSLYSData('" + StrStartTime + "','" + StrEndTime + "'," + nextPage + "," + pageSize + ",'" + UserSession + "')\">下一页</a></li>");
                    result.Append("<li class='paper_F'><a ID='InkLast'  href=\"javascript:GetSLYSData('" + StrStartTime + "','" + StrEndTime + "'," + pageNum + "," + pageSize + ",'" + UserSession + "')\">末页</a></li>");
                    result.Append("</ul>");
                    result.Append("</div>");
                    result.Append("<div class='paper_n2'>");
                    result.Append("<span id='lblCurPage'>第" + pageIndex + "/" + pageNum + "页</span>");
                    result.Append("　<span id='Label6'>每页" + pageSize + "条</span>");
                    result.Append("</div>");
                    result.Append("</td>");
                    result.Append("</tr>");
                    result.Append("</table>");
                }
            }
            return result.ToString();
        }

        /// <summary>
        /// 删除维修报警
        /// </summary>
        /// <param name="DeleteIDs"></param>
        /// <param name="UserSession"></param>
        /// <returns>1：删除失败、2：没有权限、3：删除成功</returns>
        [WebMethod]
        public int DeleteDailyManagementList(string DeleteIDs, string UserSession)
        {
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return 2;
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;
            bool flag = false;//是否有删除的权限
            if (Catering.Toolss.IsVerification(userrole.ToString(), "wxbj.aspx", "操作")) flag = true;
            if (flag)
            {
                string[] ids = DeleteIDs.Split(',');
                if (ids.Length > 0)
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        try
                        {
                            int id = Convert.ToInt32(ids[i]);
                            if (id > 0)
                            {
                                DailyManagement dm = new DailyManagement();
                                dm.Update(id, "Repair","无事");
                            }
                        }
                        catch { }
                    }
                    return 3;
                }
                return 1;
            }
            else
            {
                return 2;
            }
        }

        /// <summary>
        /// 删除上料验收
        /// </summary>
        /// <param name="DeleteIDs"></param>
        /// <param name="UserSession"></param>
        /// <returns></returns>
        [WebMethod]
        public int DeleteSLYSDataList(string DeleteIDs, string UserSession)
        {
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return 2;
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;
            bool flag = false;//是否有删除的权限
            if (Catering.Toolss.IsVerification(userrole.ToString(), "slys.aspx", "操作")) flag = true;
            if (flag)
            {
                string[] ids = DeleteIDs.Split(',');
                if (ids.Length > 0)
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        try
                        {
                            int id = Convert.ToInt32(ids[i]);
                            if (id > 0)
                            {
                                DailyManagement dm = new DailyManagement();
                                dm.Update(id, "DishTest", "合格");
                            }
                        }
                        catch { }
                    }
                    return 3;
                }
                return 1;
            }
            else
            {
                return 2;
            }
        }
        [WebMethod]
        public int DeleteAQYHDataList(string DeleteIDs, string UserSession)
        {
            UserSession = UserSession == "" ? "0" : Bind_Data_to_Controls.Decode(UserSession);
            int userrole = 0;
            string userid = UserSession;
            int companyid = 0;
            int groupid = 0;
            int classid = 0;
            bool isAdmin = false;
            Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
            Catering_Model.user userInfo = new Catering_Rules.user().GetModel(Convert.ToInt32(userid));
            if (userInfo == null) return 2;
            userrole = userInfo.URole == null ? 0 : (int)userInfo.URole;
            bool flag = false;//是否有删除的权限
            if (Catering.Toolss.IsVerification(userrole.ToString(), "aqyh.aspx", "操作")) flag = true;
            if (flag)
            {
                string[] ids = DeleteIDs.Split(',');
                if (ids.Length > 0)
                {
                    for (int i = 0; i < ids.Length; i++)
                    {
                        try
                        {
                            int id = Convert.ToInt32(ids[i]);
                            if (id > 0)
                            {
                                DailyManagement dm = new DailyManagement();
                                dm.Update(id, "temp2", "无事");
                            }
                        }
                        catch { }
                    }
                    return 3;
                }
                return 1;
            }
            else
            {
                return 2;
            }
        }
    }
}
